<%-- 
    Document   : product_category
    Created on : Mar 27, 2013, 12:43:58 PM
    Author     : DungTQ
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<c:set var="context" value="${pageContext.request.contextPath}"/>
<jsp:useBean id="checkerBean" class="core.XmlChecker"/>
<c:set var="path" value='<%=getServletContext().getRealPath("/")%>'/>
<jsp:setProperty name="checkerBean" property="realPath" value="${path}"/>



<jsp:setProperty name="checkerBean" property="webPath" value="/WEB-INF/XmlDoc/Comments.xml"/>
<c:if test="${not checkerBean.validFile}">
    <jsp:forward page="/XmlController">
        <jsp:param name="action" value="CommentXmlCheck"/>
        <jsp:param name="current" value="/client/product_category.jsp"/>
    </jsp:forward>
</c:if>

<jsp:setProperty name="checkerBean" property="webPath" value="/WEB-INF/XmlDoc/Users.xml"/>
<c:if test="${not checkerBean.validFile}">
    <jsp:forward page="/XmlController">
        <jsp:param name="action" value="UsersXmlCheck"/>
        <jsp:param name="current" value="/client/product_category.jsp"/>
    </jsp:forward>
</c:if>

<jsp:setProperty name="checkerBean" property="webPath" value="/WEB-INF/XmlDoc/UserDetails.xml"/>
<c:if test="${not checkerBean.validFile}">
    <jsp:forward page="/XmlController">
        <jsp:param name="action" value="UserDetailsXmlCheck"/>
        <jsp:param name="current" value="/client/product_category.jsp"/>
    </jsp:forward>
</c:if>
<jsp:setProperty name="checkerBean" property="webPath" value="/WEB-INF/XmlDoc/Products.xml"/>
<c:if test="${not checkerBean.validFile}">
    <jsp:forward page="/XmlController">
        <jsp:param name="action" value="ProductsXmlCheck"/>
        <jsp:param name="current" value="/client/product_category.jsp"/>
    </jsp:forward>
</c:if>
<c:import url="${checkerBean.webPath}" var="xmlProdDoc" charEncoding="UTF-8" />
<c:import url="/WEB-INF/XslDoc/products.xsl" charEncoding="UTF-8" var="xslProdDoc"/>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Products Page</title>
        <link href="${context}/res/css/main-style.css" rel="stylesheet" type="text/css" />
        <link href="${context}/res/css/restaurant-style.css" rel="stylesheet" type="text/css" />
        <link href="${context}/res/css/search-style.css" rel="stylesheet" type="text/css" />
        <link href="${context}/res/css/modal-popup-style.css" rel="stylesheet" type="text/css" />
        <link href="${context}/res/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

        <script language="JavaScript" src="${pageContext.request.contextPath}/res/js/lightbox.js"></script>
        <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/SearchScript.js"></script>
        <script>var contextPath = "${pageContext.request.contextPath}"</script>
        <script>var userNameJSP = "${sessionScope.USER_NAME}"</script>
        <script>var useridJSP = "${sessionScope.USER_ID}"</script>        
        <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/CommentScript.js"></script>
        <script language="JavaScript" src="${pageContext.request.contextPath}/scripts/UtilsScript.js"></script>
        <script language="JavaScript" src="${pageContext.request.contextPath}/res/js/jquery-1.9.1.js"></script>
        <script language="JavaScript" src="${pageContext.request.contextPath}/res/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div id="PopupContainer" class="white_content">
            <div id="content"></div>
            <img id="btnClose" src="${context}/res/img/buttonclose.png" alt="Close"/>
        </div>
        <div id="fadeOverlay" class="black_overlay">
        </div>

        <div id="page-container">
            <div id="header">
                <div class="wrapper">
                    <div class="logo-container">
                        <!-- Get the logo-->
                        <a href="${pageContext.request.contextPath}"><img src="${pageContext.request.contextPath}/res/img/logo2.png" alt="laptop.com" /></a>
                    </div>

                    <c:choose>
                        <c:when test="${empty sessionScope.USER_ID}">
                            <nav class="menu-container">
                                <a href="${pageContext.request.contextPath}">Home</a>
                                <a href="${pageContext.request.contextPath}/about-us.jsp">About us</a>
                                <a href="${pageContext.request.contextPath}/management/Register.jsp">Registry</a>
                            </nav>
                            <div id="home-login">

                                <form action="${context}/UserController?action=Login&page=client/product_category.jsp" method="POST">
                                    <table>
                                        <tr>
                                            <td colspan="1"><input type="text" name="txtUsername" id="home-username" class="home-login-textbox" placeholder="username" required/></td>
                                            <td colspan="1"><input type="password" name="txtPassword" id="home-password" class="home-login-textbox" placeholder="password" required/></td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <c:if test="${not empty requestScope.USER_ERROR}">
                                                    <p class="home-login-validation">${requestScope.USER_ERROR}</p>
                                                </c:if>
                                            </td>
                                            <td>
                                                <input type="submit" id="home-login-btn" class="home-login-button" value="LOGIN"/>
                                            </td>
                                        </tr>

                                    </table>
                                </form>
                            </div> <!-- END Home-login -->
                        </c:when>
                        <c:otherwise>
                            <nav class="menu-container">
                                <a href="${pageContext.request.contextPath}">Home</a>
                                <a href="${pageContext.request.contextPath}/about-us.jsp">About us</a>
                                <c:if test="${sessionScope.USER_ROLE=='admin'}">
                                    <a href="${pageContext.request.contextPath}/management/Admin.jsp">Admin page</a>
                                </c:if>
                            </nav>
                            <div id="personal-container">
                                <ul>
                                    <li class="my-account">
                                        <h3>Welcome ${sessionScope.USER_NAME}</h3>
                                        <h3><a href="${context}/UserController?action=Logout" method="POST">Log out</a></h3>
                                    </li>
                                </ul>
                            </div>
                        </c:otherwise>
                    </c:choose>
                    <div class="spacer" style="clear: both;"></div>
                </div>
            </div> <!-- end header -->
            <div id="middle-container">
                <div class="wrapper">                    
                    <div class="product-filter-container">
                        <div class="product-search">
                            <h3 class="product-filter-title">Search Product</h3>
                            <div id="divAuto" class="product-search-form" style="position:relative;">
                                <form name="mySearch">                                    
                                    <table>
                                        <tr>
                                            <td><input type="text" name="txtSearch" class="txt-product-search" value=""/></td>
                                        </tr>
                                        <tr>
                                            <td><input type="button" value="Search" class="btn-product-search"
                                                       onclick="search(this.form.txtSearch.value)"/></td>
                                        </tr>

                                    </table>                                                               
                                </form>
                            </div>
                        </div>
                        <div class="cart-container cart-container-absolute" id="cart-container">
                            <div id="master-items-container">

                            </div>
                        </div>
                    </div>

                    <div id="productlistSearch" class="product-list-container">                        
                        <c:if test="${empty mySearch.txtSearch}">
                            <x:transform doc="${xmlProdDoc}" xslt="${xslProdDoc}">
                                <x:param name="type" value="empty"/>
                                <x:param name="contextpath" value="${pageContext.request.contextPath}"/>
                                <x:param name="checkUsername" value="${sessionScope.USER_NAME}"/>
                            </x:transform>
                        </c:if>
                    </div>


                </div>

                <div class="spacer" style="clear: both;"></div>
            </div> <!-- end middle-container -->
            <div id="footer">
                <div class="wrapper">
                    <div id="footer-menu">
                        <ul>
                            <li><a href="${pageContext.request.contextPath}">Trang chủ</a></li>
                            <li><a href="${pageContext.request.contextPath}/about-us.jsp">Giới thiệu</a></li>
                            <li><a href="${pageContext.request.contextPath}/contact-us.jsp">Liên hệ</a></li>
                        </ul>
                    </div>
                    <div id="copy-right">
                        <p>
            	Copyright © 2013 Laptop. All rights reserved.<br>
                        </p>
                    </div>
                </div>
            </div> <!-- end footer -->
        </div>
    </body>
</html>
